/*
 * Copyright @ 2024 weili23
 * com.example.mythread.a09threadExerciseRedEnvelope 16:47
 * All right reserved.
 */

package com.example.mythread.a09threadExerciseRedEnvelope;

import java.util.Random;

/**
 * @desc:
 * @author: weili23
 * @createTime: 2024/10/21 16:47
 * @version: v1.0
 */
public class Demo {
    public static void main(String[] args){
        /*
         * 微信中抢红包用到了多线程
         * 假设100块分成3个包  最少是1元 有五个人去抢
         * 其中红包是共享数据  五个人是五条线程
         * 打印结果如果
         *   xxx抢到了红包xx元
         *   xxx抢到了红包xx元
         *   xxx抢到了红包xx元
         *   xxx没抢到红包
         *   xxx没抢到红包
         */
        MyRedEnvelope myRedEnvelope = new MyRedEnvelope();
        Thread thread1 = new Thread(myRedEnvelope,"用户1");
        Thread thread2 = new Thread(myRedEnvelope,"用户2");
        Thread thread3 = new Thread(myRedEnvelope,"用户3");
        Thread thread4 = new Thread(myRedEnvelope,"用户4");
        Thread thread5 = new Thread(myRedEnvelope,"用户5");
        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();

    }
}
